package pearson.automation;

import java.util.ArrayList;
import java.util.Calendar;

import org.testng.annotations.BeforeClass;

import pearson.automation.api.CoursesAPI;

public class BasePearsonTestWithCourseCreation extends BasePearsonTestLogin {
    
    protected static final String courseName = String.format(
            "Autotests DeVry Course %1$tm%1$te%1$tk%1$tM%1$tS",
                Calendar.getInstance());
    protected String moduleName = "Course Home";
    protected String sectionName = "Course Overview";
    protected static ArrayList<String[]> myLibraryElements
                = new ArrayList<String[]>();
    protected String userID = userData.getProperty("defaultUserid");
    /**
     * FIXME: for concurrent run will cause an issue
     */
    protected static String courseURL = null;
    protected static String courseID = null;

    @BeforeClass(groups = "Base")
    public void doBeforeClass() {
        super.doBeforeClass();
    info("Creating a course via API");
        browser.getDriver().navigate().to(browser.getStartBrowserURL());
        // Clear existing courses 
        //cleanUpCoursesViaAPI(userID);
        // Create a course via API and rename it
        courseID = new CoursesAPI().createDevRyCourse(userID);
        new CoursesAPI().renameCourse(userID, courseID, courseName);
        // Build a course URL
        courseURL = String.format("%1$sos/course/id/%2$s",
                browser.getStartBrowserURL(), courseID);
    }
    
}
